<?php

/**
 * 生活服务后台管理
 * @copyright (c) 2013, Alvin
 * 
 */
class CardThemeAction extends AdminAction {

    public function _initialize() {
        parent::_initialize();
    }

    public function edit() {
        if (IS_POST) {
            //图片上传
            $savePath                = "/Public/Uploads/" . date("Ymd") . "/";
            $file                    = $this->upload($savePath);
            $_POST['icon_url']       = $savePath . $file['icon_url']['savename'];
            $_POST['background_url'] = $savePath . $file['background_url']['savename'];
            $res                     = M('CardTheme')->add($_POST);
            if ($res) {
                $this->success('添加模版成功');
            } else {
                $this->success('添加模版失败');
            }
        } else {
            $this->display();
        }
    }

    public function themedelete() {
        $id = (int) $this->_get("id");
        if (M('CardTheme')->delete($id)) {
            $this->success("删除名片模版成功！");
        } else {
            $this->error("删除名片模版失败！");
        }
    }

}

?>
